<pre>
<?php
$rID="";
/*
//获取用户数据
$post_result = http_request('https://api.v2.rainyun.com/user/', 'GET') ;
var_dump( $post_result['rjson'] );

*/
//获取云服务器列表
$options = '{"columnFilters":{"rcs.ID":"' . $rID . '"},"sort":[],"page":1,"perPage":20}';
$post_result = http_request('https://api.v2.rainyun.com/product/rcs/?options='. urlencode($options) , 'GET') ;
//var_dump( $post_result['rjson'] );
//print_r($post_result['rjson']['data']['Records']);
$post_result = $post_result['rjson']['data']['Records'];
//print_r($post_result['0']);
foreach ($post_result as $value)
{
    echo "<br/>服务器 ID：$value[ID]";
    echo "<br/>机器标签 ：$value[Tag]";
    echo "<br/>运行状态 ：$value[Status]";
    echo "<br/>系统类型 ：$value[OsName]";
    echo "<br/>系统密码 ：$value[DefaultPass]";
    echo "<br/>创建时间 ：" . date("Y-m-d H:i:s",$value['CreateDate']);
    echo "<br/>到期时间 ：" . date("Y-m-d H:i:s",$value['ExpDate']);
    $yc = "";
    $result = http_request("https://api.v2.rainyun.com/product/rcs/$value[ID]/vnc?console_type=novnc" , 'GET') ;
    if(isset($result['rjson']) && isset($result['rjson']['data']) && isset($result['rjson']['data']['VNCProxyURL'] ) )
        $yc .= "<a href='" . $result['rjson']['data']['VNCProxyURL'] . "'>novnc</a>  ";
    $result = http_request("https://api.v2.rainyun.com/product/rcs/$value[ID]/vnc?console_type=xtermjs" , 'GET') ;
    if(isset($result['rjson']) && isset($result['rjson']['data']) && isset($result['rjson']['data']['VNCProxyURL'] ) )
        $yc .=  "<a href='" . $result['rjson']['data']['VNCProxyURL'] . "'>xtermjs</a>";
    if ($yc != "")
        echo   "<br/>远程操作 ：" . $yc;
    echo "<br/>";
    echo "<br/>";
}



 
/* 
// POST请求示例 
$post_url = 'https://example.com/api/post_data';  
$post_data = ['name' => 'John', 'age' => 30]; 
$post_headers = ['Content-Type' => 'application/x-www-form-urlencoded']; 
$post_cookies = ['token' => 'abcdef']; 
$post_result = curl_request($post_url, 'POST', $post_data, $post_headers, $post_cookies); 
echo $post_result; 
 
 */
?>

<?php
function http_request($url, $method = 'GET', $data = null, $headers = ['x-api-key: DvWEkRjvpdDr5xotGmTqK38rlzbjIxVx'], $cookies = '') { 
    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL, $url); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); 
    if ($method === 'POST') { 
        curl_setopt($ch, CURLOPT_POST, 1); 
        if ($data)             curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 
    } 
    if (!empty($headers))         curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);  
    if (!empty($cookies))         curl_setopt($ch, CURLOPT_COOKIE, $cookies);  
    $response = curl_exec($ch); 
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); 
    curl_close($ch);  
    return ['response' => $response, 'http_code' => $http_code, 'rjson' =>json_decode($response,1) ]; 
}  
?>
</pre>